package com.kjsdfgk.hjmdsf.livev3.mvp.model;

import android.app.Application;
import android.util.Base64;

import com.google.gson.Gson;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;

import com.jess.arms.di.scope.ActivityScope;
import javax.inject.Inject;

import com.kjsdfgk.hjmdsf.app.api.service.CommonService;
import com.kjsdfgk.hjmdsf.app.entity.JJKKTokenJson;
import com.kjsdfgk.hjmdsf.app.entity.KjhfsJson;
import com.kjsdfgk.hjmdsf.livev3.mvp.contract.LiveV3Contract;

import io.reactivex.Observable;


/**
 * ================================================
 * Description:
 * <p>
 * Created by MVPArmsTemplate on 04/27/2020 23:28
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
 * <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
 * ================================================
 */
@ActivityScope
public class LiveV3Model extends BaseModel implements LiveV3Contract.Model{
    @Inject
    Gson mGson;
    @Inject
    Application mApplication;

    @Inject
    public LiveV3Model(IRepositoryManager repositoryManager) {
        super(repositoryManager);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mGson = null;
        this.mApplication = null;
    }

    @Override
    public Observable<JJKKTokenJson> getJJKKTokenJson() {
//        https://apid.bdxqhzs.com/s1/register/uuid/d30a10e0ed84d1cf?model=Xiaomi MI MAX 3&platform=android&key=e92c2fdb23428aa09f7a5e05bd879db6f0c62622936cea0f7de8b427a3d24689&version=3.9.2&lang=CN
        String host = "YXBpZC5iZHhxaHpzLmNvbQ==";
        host =  new String(Base64.decode(host.getBytes(), Base64.DEFAULT));
        String url = "https://"+host+"/s1/register/uuid/d30a10e0ed84d1cf?model=Xiaomi MI MAX 3&platform=android&key=e92c2fdb23428aa09f7a5e05bd879db6f0c62622936cea0f7de8b427a3d24689&version=3.9.2&lang=CN";
        url = "https://apid.hzyzcn.com/s1/register/uuid/d30a10e0ed84d1cf?model=Xiaomi MI MAX 3&platform=android&key=e92c2fdb23428aa09f7a5e05bd879db6f0c62622936cea0f7de8b427a3d24689&version=3.9.2&lang=CN";
        Observable<JJKKTokenJson> result = mRepositoryManager.obtainRetrofitService(CommonService.class)
                .getJJKKTokenJson(url );
        return result;
    }

    @Override
    public Observable<KjhfsJson> getKjhfsData(int version) {
       Observable<KjhfsJson> result = mRepositoryManager.obtainRetrofitService(CommonService.class)
                .getKjhfsDataApi( " https://gitee.com/izywei/LiveMvp/raw/master/data/kjhfs"+version+".json" );
        return result;
    }
}